<template>
  <div class="shareIndex" v-if="initData.detail">
    <!-- <van-nav-bar title left-arrow @click-left="onClickLeft" fixed /> -->
    <div class="box1">
      <div class="left">
        <img src="../assets/images/logo.png" alt />
        <span>从这里发现更多精彩</span>
      </div>
      <div class="right" @click="downloadApp">好啊</div>
    </div>
    <div class="box2">
      <!-- <div class="pic">
        <img src="../assets/images/3@2x.png" alt />
        <img src="../assets/images/3@2x.png" alt />
        <img src="../assets/images/2@2x.png" alt />
      </div> -->
      <!-- <div class="redEnvelope">
        <div class="headImg">
          <img :src="initData.detail.avatar" alt />
        </div>
        <div class="redEnvelopeInfo">
          <div class="price">¥ {{initData.rob_money}}</div>
          <div class="note">{{initData.detail.title}}</div>
        </div>
      </div> -->
    </div>
    <div class="box3">
      <img :src="initData.detail.images" alt />
    </div>
    <div class="box4">
      <div class="left">
        <div class="pic">
          <img :src="initData.detail.avatar" alt />
        </div>
        <div class="name">{{initData.detail.nickname}}</div>
        <div class="cardImg">
          <!-- <img src="../assets/images/mingpian@2x.png" alt /> -->
        </div>
      </div>
      <div class="right">+关注</div>
    </div>
    <div class="artical">
      <div>
        
        <!-- <div class="articalTitle">文章1984年出生于陕西省西安市。</div> -->
        <div
          class="articalContent"
        >{{initData.detail.content}}</div>
        <div class="box5">
          <div class="left">{{initData.detail.createtime*1000|changeNum|formatDate("MM-dd")}}</div>
          <div class="right">
            <div class="item">
              <img src="../assets/images/praise3.png" alt />
              <span>{{initData.detail.likes}}</span>
            </div>
            <div class="item">
              <img src="../assets/images/messa.png" alt />
              <span>{{initData.detail.comments}}</span>
            </div>
            <div class="item">
              <img src="../assets/images/share.png" alt />
              <span>{{initData.detail.views}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="box6">
      <div class="left" v-for="(item,index) in initData.detail.rob_list" :key="index">
        <div class="pic">
          <img :src="item.avatar" alt />
        </div>
        <div class="text" v-if="index==0">
          <div class="date">{{item.createtime*1000|changeNum|formatDate("hh:mm")}}</div>
          <div>最佳状元</div>
        </div>
      </div>
      <!-- <div class="right">
        <div class="picList">
          <img src="../assets/images/tou.png" alt />
          <img src="../assets/images/tou.png" alt />
          <img src="../assets/images/tou.png" alt />
          <img src="../assets/images/tou.png" alt />
          <img src="../assets/images/tou.png" alt />
          <img src="../assets/images/tou.png" alt />
        </div>
        <div class="mark">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>-->
    </div>
    <div class="footer">
      <div class="left">
        <div class="pic">
          <img src="../assets/images/logo.png" alt />
        </div>
        <div class="text">
          <div class="row1">现信，发现营销新方式</div>
          <div class="row2">现金红包抢不完 热门活动报不完</div>
        </div>
      </div>
      <div class="right" @click="downloadApp">立即前往</div>
    </div>
    <div v-if="showBind">
      <bindPhone :uid="false" :activity_id="false"></bindPhone>
    </div>
  </div>
</template>
<script>
import vuefilter from "../common/vuefilter.js";
export default {
  name: "shareIndex",
  filters: {
    formatDate: vuefilter.formatDate,
    changeNum: vuefilter.changeNum
  },
  data() {
    return {
      initData: {},
      //红包ID
      id: "",
      uid: "",
      activity_id: "",
      showBind:false
    };
  },
  mounted() {
    if (this.$route.query.uid) {
      this.uid = this.$route.query.uid;
    }
    if (this.$route.query.activity_id) {
      this.id = this.$route.query.activity_id;
    } else {
      this.id = 3323;
    }
    // if (!this.$cookies.get("token")) {
    //   this.$router.push({
    //     path: "/login",
    //     query: {
    //       uid: this.uid,
    //       activity_id: this.id
    //     }
    //   });
    //   return;
    // }
    this.getInitData();
  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    //获取初始化数据
    async getInitData() {
      let params = {
        token: this.$cookies.get("token"),
        id: this.id
      };
      const res = await this.$axios.post(this.$api.h5GetRedDetail , params);
      if (res.code == 1) {
        this.initData = res.data;
      } else {
        this.$message({
          message: "获取红包数据失败：" + res.msg,
          type: "error"
        });
      }
    },
    //下载APP
    downloadApp() {
      if (this.$cookies.get("first_login")!=0) {
        this.showBind = true;
        return;
      }
      var u = navigator.userAgent;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
      var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isiOS) {
        window.location.href = this.$api.downloadUrl;
      }
      if (isAndroid) {
        window.location.href = this.$api.downloadUrl;
      }
    }
  }
};
</script>
<style scoped>
.shareIndex {
  /* height: 100vh; */
  background: #fff;
  /* padding-top: 0.46rem; */
}
.box1 {
  width: 100%;
  height: 0.5rem;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 0px 7px 0px rgba(0, 0, 0, 0.1);
  padding: 0 0.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.box1 .left {
  display: flex;
  align-items: center;
}
.box1 .left img {
  width: 0.33rem;
  height: 0.33rem;
}
.box1 .left span {
  padding-left: 0.15rem;
  font-size: 0.12rem;
  font-family: PingFangSC;
  font-weight: 400;
  color: rgba(53, 53, 53, 1);
}
.box1 .right {
  width: 0.74rem;
  height: 0.25rem;
  border: 1px solid #00c6d8;
  color: #00c6d8;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50px;
}
.box2 {
  width: 100%;
  height: 0.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.box2 .pic {
  display: flex;
  align-items: center;
}
.box2 .pic img {
  height: 0.04rem;
  margin-right: 0.05rem;
}
.box2 .redEnvelope {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1.3rem;
  height: 0.5rem;
  display: flex;
  background: #e76050;
  border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  align-items: center;
  padding-left: 0.06rem;
  box-shadow: 0px 0px 7px 0px #e76050;
}
.box2 .redEnvelope .headImg img {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
}
.box2 .redEnvelope .redEnvelopeInfo {
  padding-left: 0.02rem;
  font-size: 0.12rem;
  color: #fff;
}
.box2 .redEnvelope .redEnvelopeInfo .price {
  margin-bottom: 0.05rem;
}
.box3 img {
  width: 100%;
}
.box4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.15rem 0.23rem;
}
.box4 .left {
  display: flex;
  align-items: center;
}
.box4 .left .pic img {
  width: 0.47rem;
  height: 0.47rem;
  border-radius: 50%;
}
.box4 .left .name {
  width: 1.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.13rem;
}
.box4 .left .cardImg img {
  width: 0.18rem;
  height: 0.14rem;
  margin-left: 0.1rem;
}
.box4 .right {
  width: 0.6rem;
  height: 0.22rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #00c6d8;
  border-radius: 50px;
  color: #fff;
  font-size: 0.12rem;
}
.artical {
  padding: 0 0.15rem;
}
.artical .articalTitle {
  font-size: 0.12rem;
  color: #282727;
  margin-bottom: 0.2rem;
}
.artical .articalContent {
  font-size: 0.12rem;
  color: #282727;
}
.box5 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 0 0.15rem;
  margin-top: 0.16rem;
}
.box5 .left {
  color: #ccc;
}
.box5 .right {
  display: flex;
}
.box5 .right .item {
  margin-left: 0.2rem;
  display: flex;
  align-items: center;
}
.box5 .right .item img {
  width: 0.1rem;
  height: 0.1rem;
}
.box5 .right .item span {
  font-size: 0.12rem;
  color: #ccc;
  padding-left: 0.04rem;
}
.box6 {
  display: flex;
  background: #fff;
  padding: 0.2rem 0.15rem;
  width: 100%;
  overflow: hidden;
}
.box6 .left {
  display: flex;
  padding-right: 0.1rem;
}
.box6 .left img {
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
}
.box6 .left .text {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.12rem;
  color: #3b3a3a;
  padding-left: 0.06rem;
  padding-right: 0.08rem;
  border-right: 1px solid #eeeeee;
}
.box6 .left .text .date {
  color: #00c6d8;
}
.box6 .right {
  padding-left: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: auto;
}
.box6 .right .picList img {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
}
.box6 .right .mark span {
  width: 0.04rem;
  height: 0.04rem;
  background: #000000;
  border-radius: 50%;
  display: inline-block;
}
.footer {
  display: flex;
  width: 100%;
  height: 0.5rem;
  padding: 0.1rem 0.15rem;
  justify-content: space-between;
  background: #fff;
  box-shadow: 0px 0px 7px 0px #cccccc;
}
.footer .left {
  display: flex;
  align-items: center;
}
.footer .left img {
  width: 0.33rem;
  height: 0.33rem;
}
.footer .left .text {
  padding-left: 0.13rem;
  font-size: 0.12rem;
  font-family: PingFangSC-Medium;
  font-weight: 500;
  color: rgba(53, 53, 53, 1);
}
.footer .right {
  width: 0.8rem;
  height: 0.3rem;
  border: 1px solid #00c6d8;
  color: #00c6d8;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 0;
  border-radius: 0.05rem;
}
</style>


